# -*- coding: utf-8 -*-,
# @File : 1.线程池.py,
# @Author : lidong,
# @IDEA: PyCharm
# @Time :  2022/5/11 14:38

import requests
import time
from multiprocessing.dummy import Pool

def get_request(url):
    page_text = requests.get(url).text
    return len(page_text)


# if __name__ == '__main__':
#     start = time.time()
#     urls = [
#     "http://127.0.0.1:5000/bobo",
#     "http://127.0.0.1:5000/jay",
#     "http://127.0.0.1:5000/tom",
#     ]
#     for i in urls:
#         res = get_request(i)
#         print(res)
#     print('耗时',time.time()-start)

if __name__ == '__main__':
    start = time.time()
    urls = [
    "http://127.0.0.1:5000/bobo",
    "http://127.0.0.1:5000/jay",
    "http://127.0.0.1:5000/tom",
    ]
    pool = Pool(3)
    result_list= pool.map(get_request, urls)
    print(result_list)
    print('耗时', time.time() - start)